<template>
  <div>
    <h2>团队管理</h2>
    <el-button @click="dddd()">deawersdtfygmo</el-button>

    <el-tabs v-model="activeName" @tab-click="handleClick">
    <el-tab-pane label="我管理的团队" name="first"></el-tab-pane>
    <el-tab-pane label="我加入的团队" name="second"></el-tab-pane>
    <!-- <el-tab-pane label="角色管理" name="third">角色管理</el-tab-pane> -->
    <!-- <el-tab-pane label="定时任务补偿" name="fourth">定时任务补偿</el-tab-pane> -->
  </el-tabs>
    <!-- 查询 -->
    <el-form ref="form" inline :model="form" label-width="80px">
  <el-form-item label="">
    <el-input v-model="form.name" placeholder="请输入关键字"></el-input>
  </el-form-item>
  <el-form-item label="机构">
        <el-select v-model="form.jid" placeholder="请选择" clearable>
          <el-option
            v-for="t in insList"
            :key="t.id"
            :label="t.name"
            :value="t.id"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-button type="primary" icon="el-icon-search" @click="findPage()">搜索</el-button>
  </el-form>
  <el-button type="primary" @click="xinzeng()">新增医生团队</el-button>
     <!--  表  -->
     <el-table
      ref="multipleTable"
      :data="tableData"
      tooltip-effect="dark"
      style="width: 95%"
      @selection-change="handleSelectionChange"
    >
      <el-table-column type="selection" width="55"> </el-table-column>
      <el-table-column label="头像" width="120">
        <template slot-scope="scope">
          <div style="float: left; " >
            <img
              :src="scope.row.photo"
              style="width: 50px; height: 36px"/>
          </div>
          </template>
      </el-table-column>
      <el-table-column prop="id" label="编号" width="80"> </el-table-column>
      <el-table-column prop="name" label="团队名称" width="120px"></el-table-column>
      <el-table-column prop="leader" label="团队长" width="120px"></el-table-column>

      <el-table-column  prop="lname" label="团队标签" width="120px">
        <template slot-scope="scope">
            <span style="color: red;">{{ scope.row.lname}}</span>
        </template>
      </el-table-column>
      
      <el-table-column prop="iname" label="所属机构" width="150px"></el-table-column>
      <el-table-column prop="signedCount" label="签约人数" width="80px"></el-table-column>
      <el-table-column prop="score" label="评分" width="80px"></el-table-column>
      <el-table-column prop="status" label="状态" width="150px">
        <template slot-scope="scope">
            <el-tooltip :content="scope.row.status">
            <el-switch
              v-model="scope.row.status"
              active-color="#13ce66" inactive-color="#ff4949"
              active-value="1" inactive-value="2" active-text="开启"  inactive-text="禁用"
              @change="updateStatus(scope.row.id,scope.row.status)">
            </el-switch>
          </el-tooltip>
        </template>
      </el-table-column>
      <!-- 操作 -->
      <el-table-column fixed="right" label="操作" width="190">
        <template slot-scope="scope">
             <el-link type="primary" @click="dd(scope.row)">查看详情</el-link>
             <span>&nbsp;&nbsp;&nbsp;</span>
      <el-link type="danger" @click="sc(scope.row.id)">解散退队</el-link>
        </template>
      </el-table-column>
    </el-table>
    <!--  分页  -->
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="pn"
      :page-sizes="[5, 9, 13, 15]"
      :page-size="ps"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total">
    </el-pagination>
<!-- 详情 -->
<el-dialog title="我管理的团队详情" fullscreen="true" :visible.sync="dialogFormVisible">
  <!-- <div slot="footer"  class="dialog-footer"> -->
    <el-button type="primary" @click="dialogFormVisible = false" style="float: right;">返 回</el-button>
    <!-- <el-button type="primary" @click="dialogFormVisible = false">确 定</el-button> -->
  <!-- </div> -->
    <div>
        <span style="margin-right: 120px;">团队编号：&nbsp;&nbsp;&nbsp;{{ xq.id }}</span>
        <span style="margin-right: 120px;">团队名称：&nbsp;&nbsp;&nbsp;{{ xq.name }}</span>
        <span style="margin-right: 120px;">团队头像：&nbsp;&nbsp;&nbsp;
            <img :src="xq.photo" style="width: 50px; height: 50px;" />
        </span>
        <span style="margin-right: 120px;">团队标签：&nbsp;&nbsp;&nbsp;{{ xq.lname }}</span>
    </div>
    <div>
        <span>机构地址：&nbsp;{{ xq.iaddress }}</span>&nbsp;&nbsp;&nbsp;
        <span>团队评分：&nbsp;{{ xq.score }}</span>&nbsp;&nbsp;&nbsp;
        <span>分享量：&nbsp;{{ xq.shareCount }}</span>&nbsp;&nbsp;&nbsp;
        <span>签约人数：&nbsp;{{ xq.signedCount }}</span>&nbsp;&nbsp;&nbsp;
    </div>
    <div>
        <span>邀请加入二维码</span>
        <img src="https://yuanss.oss-cn-beijing.aliyuncs.com/one-phl/2024/9/27/add.png" style="width: 150px; height: 150px;" />
    </div>
    <p>创建时间：{{ xq.createTime }}</p>
    <p>创建人：</p>
    <el-form ref="xq" :model="xq" label-width="80px">
        <el-form-item label="即时配送：">
            <el-switch
    v-model="xq.status"
    active-color="#13ce66"
    inactive-color="#ff4949"
    active-value="1"
    inactive-value="2"
active-text="开启"  inactive-text="禁用" >
  </el-switch>
        </el-form-item>
    
  </el-form>
  <!--  -->
    <!--  -->
        <h2>团队成员</h2>
        <div id="dd" >
        <!-- <span style="float: left;">初级包</span> -->
        <div  v-for="item in doctor" :key="item.id" id="chu" @click="show(item)">
            <div id="img">
                <img  :src="item.photo"  style="width: 120px; height: 120px;">
            </div>
            <div id="shuju">
              <span style="font-size: 20px;">{{ item.name }}</span>
              <span>{{ item.rname }}</span><br><br>
                <span>签约人数：{{ item.share }}</span><br/><br>
                <span >评分{{ item.score }}(999人评价)</span><br /><br>
            </div>
        <el-button size="medium" style="float: right; margin-right: 10px;" @click="show(item)">
          医师详情</el-button>    
        </div>
      </div><br><br><br><br><br>
    
      
<!-- 服务包 -->
 <h2>服务包</h2>
<div id="dd" >
        <div  v-for="item in findDiv" :key="item.id" id="chu" @click="fuwushow(item)">
            <div v-if="item.status === '1'" style="float: right; width: 50px; height: 20px; margin-right: 5px; margin-top: 5px; background-color: green; color: white; text-align: center; border-radius: 5px;">   使用中</div>
            <div v-if="item.status === '2'" style="float: right; width: 50px; height: 20px; margin-right: 5px; margin-top: 5px; background-color: blue; color: white; text-align: center; border-radius: 5px;">    待审核</div>
            <div v-if="item.status === '3'" style="float: right; width: 50px; height: 20px; margin-right: 5px; margin-top: 5px; background-color: red; color: white; text-align: center; border-radius: 5px;" > 已停用  </div>
            <div v-if="item.status === '4'" style="float: right; width: 50px; height: 20px; margin-right: 5px; margin-top: 5px; background-color: brown; color: white; text-align: center; border-radius: 5px;">  已驳回</div>
            <div id="img">
                <img  :src="item.photo"  style="width: 100%;height: 150px;">
            </div>
            <div id="shuju">
              <span>{{ item.name }}</span><br><br>
                <span >{{ item.grade }}</span><br/><br>
                <span >服务对象：{{ item.sobject }}</span><br /><br>
                <span id="lname" >{{ item.lname }}</span>
            </div>
        </div>
      </div>
      <div id="ddss" >
      <h2>医生加入团队申请</h2>
        <!-- <span style="float: left;">初级包</span> -->
        <div  v-for="item in doctor2" :key="item.id" id="chu" >
            <div id="img">
                <img  :src="item.photo"  style="width: 120px; height: 120px;">
            </div>
            <div id="shuju">
              <span style="font-size: 20px;">{{ item.name }}</span>
              <span>{{ item.rname }}</span><br><br>
                <span>签约人数：{{ item.share }}</span><br/><br>
                <span >评分{{ item.score }}(999人评价)</span><br /><br>
            </div>
            <div id="sqing" style="display: flex; ">
            <el-button type="primary" @click="tongDoctor(item)">通过</el-button>
            <el-button type="danger" @click="jueDoctor(item)">拒绝</el-button>
           <el-button size="medium" style="float: right; margin-right: 10px;" @click="show(item)"> 医师详情</el-button>    
        </div>
          </div>
      </div><br><br><br><br><br>

  <!-- <div slot="footer"  class="dialog-footer"> -->
    <!-- <el-button @click="dialogFormVisible = false" style="float: left;">取 消</el-button> -->
    <!-- <el-button type="primary" @click="dialogFormVisible = false">确 定</el-button> -->
  <!-- </div> -->
</el-dialog>
<!-- 抽屉-医生信息 -->
<el-drawer  :visible.sync="drawer" :with-header="false">
  <h3>医师信息</h3>
    <div>
      <span>医生编号：{{ doctorXq.id }}</span>&nbsp;&nbsp;&nbsp;
      <span>医生姓名：{{ doctorXq.doctorName }}</span> &nbsp;&nbsp;&nbsp;
       <span>
        {{ doctorXq.sex == 1 ? '男' : '女' }}
      </span>
    </div>
   <img :src="doctorXq.photo" style="width: 100px; height: 100px;"><br>
  <p>角色：{{ doctorXq.rname }}  </p>
  <p>医生简介：{{ doctorXq.intro }}   </p>
  <p>医生擅长：{{ doctorXq.shanchang }}   </p>
  <p>加入团队：{{ doctorXq.iname }}/{{ doctorXq.tname }}   </p>
  <p>签约人数：{{ doctorXq.share }}   </p>
  <p>创建时间：{{ doctorXq.createTime }}</p>
</el-drawer>


 <el-dialog title="服务包详情" fullscreen="true" :visible.sync="dialogTableVisible2">
    <div id="baoxq">
        <div style="float: left;margin-left: 20px;">
            <img :src="pojo.photo" id="ximg">
        </div>
        <div id="rxq">
            <h3>{{pojo.name}}<span style="margin-left: 20px;">{{ pojo.grade }}</span></h3> 
            <p>服务标签：{{ pojo.lname }}</p>
            <p>订购价： <span style="color: red;">￥{{ pojo.price }}</span></p>
            <p>服务对象： {{ pojo.sobject }}</p>
            <p>服务介绍： {{ pojo.introduce }}</p>
        </div>
    </div>
    <!-- 包下的服务列表 -->
  <el-table :data="itempmList">
    <el-table-column property="id" label="编号" width="150"></el-table-column>
    <el-table-column property="name" label="名称" width="200"></el-table-column>
    <el-table-column property="number" label="次数"></el-table-column>
    <el-table-column property="type" label="项目类型"></el-table-column>
    <el-table-column property="introduce" label="项目介绍"></el-table-column>
  </el-table>
  <div slot="footer" class="dialog-footer" style="float: left;">
    <el-button type="primary" >编辑</el-button>
<!-- 点击停用 3 -->
  <el-button type="danger" v-if="pojo.status === '1'" @click="updateStatus(pojo.id,status=3)">停用</el-button>
  <!-- 点击使用 1 -->
  <el-button type="success" v-if="pojo.status === '2'" @click="updateStatus(pojo.id,status=1)">审核通过</el-button>
  <!-- 4 -->
  <el-button type="danger" v-if="pojo.status === '2'" @click="updateStatus(pojo.id,status=4)">审核驳回</el-button>
   <!-- 1 -->
  <el-button type="danger" v-if="pojo.status === '3'" @click="updateStatus(pojo.id,status=1)">启用</el-button>
  <el-button @click="dialogTableVisible2 = false">返回</el-button>
  </div>
</el-dialog> 
<!--  -->
<el-button type="text" @click="dialog = true">打开嵌套 Form 的 Drawer</el-button>

<el-drawer
  title="我嵌套了 Form !"
  :before-close="handleClose"
  :visible.sync="dialog"
  direction="ltr"
  custom-class="demo-drawer"
  ref="drawer"
  >
  <div class="demo-drawer__content">
    <el-form :model="form">
      <el-form-item label="活动名称" :label-width="formLabelWidth">
        <el-input v-model="form.name" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="活动区域" :label-width="formLabelWidth">
        <el-select v-model="form.region" placeholder="请选择活动区域">
          <el-option label="区域一" value="shanghai"></el-option>
          <el-option label="区域二" value="beijing"></el-option>
        </el-select>
      </el-form-item>
    </el-form>
    <div class="demo-drawer__footer">
      <el-button @click="dialog=false">取 消</el-button>
      <el-button type="primary" @click="dialog=false">确定</el-button>
    </div>
  </div>
</el-drawer>
  </div>
</template>

    <script>
import axios from "axios";
// import { find } from "core-js/core/array";
export default {
  data() {
    return {
      activeName:'',
      form: {},
      tableData:[],
      pn: 1,
      ps: 7,
      total: 0,
      multipleSelection: [],
      insList: [],
      dialogFormVisible:false,  
      dialogTableVisible2:false,
      xq:{},
      doctor:[],
      doctor2:[],
      drawer: false,
      doctorXq:{},
      findDiv:[],
      itempmList:[],
      pojo:{},
      dialog: false,

    };
  },
  methods: {

    dddd(){
      axios.get('/team/dd')
    },

    //解散团队
    sc(id){

      this.$confirm('此操作将永久解散该团队,并通知团队医生 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          axios.post(`team/deleteTeam/${id}`).then(res=>{
        this.$message.success(res.data.data);
        this.findPage();  
          this.$message({
            type: 'success',
            message: '解散成功!'
          });
        })
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          });          
        });
    },
    // 申请医生通过-拒绝
    tongDoctor(item){
      const id = item.id;
      const tid = item.tid;
      console.log(JSON.stringify(item)+"1234567890-23456789123456781234567345678934")
      axios.post(`team/tongguo/${id}/${tid}`).then(res=>{
        this.$message.success(res.data.data);
      })
    },
    jueDoctor(item){
      console.log(item)
      const id = item.id;
      const tid = item.tid;
   axios.post(`team/jujue/${id}/${tid}`).then(res=>{
        this.$message(res.data.data);
      })
    },
    //  包下的服务列表
    fuwushow(item) {
            this.pojo = item;
            let id = item.id;
            // console.log(id+"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
            if(id!=null){
                axios.post(`/service/findItempm/${id}`).then((res) => {
                    console.log(res.data.data);
                    this.itempmList = res.data.data;
                    this.dialogTableVisible2 = true;
                });
            }
        },
        // ---------------------------------------------        -----------------------------------------------
    // findAll(){
    //   axios.post(`service/findTeamService`,this.form).then((res) => {
    //       this.findDiv = res.data.data;
    //       console.table(this.findDiv);
    //   });

    //   },

    show(item){
      this.doctorXq=item;
      this.drawer = true;
    },

    handleClick(tab, event) {
        console.log(tab, event);
      },
      dd(row){
        console.log(JSON.stringify(row)+"XXXXXXXXXXXXXXXXXXX");
        this.dialogFormVisible = true;
        this.xq=row;
        //团队医生信息查询
        axios.post(`team/findTeamDoctor`,row).then((res) => {
            // this.doctor=res.data.data;
            const dd = res.data.data;
            this.doctor = dd.zlDoctor1;
            this.doctor2 = dd.zlDoctor2;
            console.log(JSON.stringify(this.doctor+"----------"+this.doctor2)+"1234567890-23456789123456781234567345678934");
        });
        const id = row.id;
        axios.post(`service/findTeamService/${id}`,).then((res) => {
          this.findDiv = res.data.data;
          console.table(this.findDiv);
      });
      },
        //状态变更
    updateStatus(id,status){
      console.log(id+"--------"+status)
      axios.post(`service/updateStatus/${id}/${status}`).then((res) => {
        this.dialogTableVisible2 = false;
        this.findAll();
        });
    },
    //查询机构列表
    findInstitution() {
        axios.post("institution/findName").then((res) => {
            this.insList = res.data.data;
            console.log(this.insList);
        });
    },
    // 分页查询
    findPage() {
    console.log(JSON.stringify(this.form)+"ffffffffffffffffffffff");
      axios.post(`team/findPage/${this.pn}/${this.ps}`, this.form).then((res) => {
        this.tableData = res.data.data.teamIPage.records;
        this.total = res.data.data.teamIPage.total;
        const ss = res.data.data.str;
          if(ss != null){
             this.$notify({
               title: '啊啊啊',
               message: ss,
               duration: 0
           });
        }
      });
    },
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
      this.ps = val;
      this.findPage();
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
      this.pn = val;
      this.findPage();
    },
    //多选框数组
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
  },
  created() {
    this.findPage();
    this.findInstitution();
    // this.findAll();
  },
};
</script>

<style scoped>

img{border-radius: 10px;}
.no-border .el-input__inner {
  border: none !important;
}
#dd {
    /* width: 1100px; */
    height: 210px;
    /* border: 2px solid #4800ff; */
    /* margin-bottom: 100px; */
  }
  #ddss{
    width: 1100px;
    height: 210px;
    /* border: 2px solid #4800ff; */
    margin-top: 250px;
  }
  #sqing{
    width: 400px;
    height: 40px;
    /* border: 2px solid #4800ff; */
  }
  #chu {
    width: 340px;
    height: 175px;
    /* border: 4px solid #1eed0c; */
    float: left;
    margin-left: 20px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    transition: background-color 0.3s ease;
    margin-top: 20px;
  }
  #chu:hover {
    /* background-color: rgb(55, 195, 237); */
    background-color: rgb(242, 253, 255);
    /* opacity: 0.1; */
  }
  #img {
    width: 36%;
    height: 120px;
    /* border: 2px solid #3518a9; */
    border-radius: 10px;
    float: left;
    margin-top: 5px;
    margin-left: 10px;
  }
  #shuju {
    display: block;
    width: 56%;
    height: 120px;
    /* border: 2px solid #250e0e; */
    float: right;
    margin-top: 10px;
  }
  #ct{
    background: #f36d6d;
  }
  #baoxq{
    width: 1200px;
    height: 300px;
    border: #e81c1c 2px solid;
    background: rgb(168, 255, 127);
    border-radius: 10px;
  }
  #ximg{
    width: 220px;
    height: 220px;
    border: #a02727 2px solid;
    border-radius: 10px;
    margin-top: 40px;
    margin-right: 60px;
  }
  #rxq{
    width: 800px;
    height: 220px;
    border: #a02727 2px solid;
    border-radius: 10px;
    margin-top: 40px;
    margin-right: 20px;
    float: left;
  }
</style>




